﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataView_DetailsView实现添加修改删除.aspx.cs" Inherits="数据访问控件_DataView_DetailsView实现添加修改删除" %>

<%@ Register assembly="web表单验证控件" namespace="CheckForm" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body alink="GriDview">
    <form id="form1" runat="server">
    <div>
    
        <cc1:FormValidation ID="FormValidation1" runat="server" datatype="Chinese" 
            是否验试="验试" 验证表单名="form1">
        </cc1:FormValidation>
    
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    
        <asp:SqlDataSource ID="detailView" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:mrsosoConnectionString %>" 
            DeleteCommand="DELETE FROM [AskClass] WHERE [ClaId] = @original_ClaId AND [ClaName] = @original_ClaName AND [ClaParId] = @original_ClaParId AND [ClaNavIdList] = @original_ClaNavIdList AND [ClaDis] = @original_ClaDis AND [iCount] = @original_iCount AND [Depth] = @original_Depth AND [SpellName] = @original_SpellName AND [ClaNavIdList1] = @original_ClaNavIdList1 AND [ClaSort] = @original_ClaSort" 
            InsertCommand="INSERT INTO [AskClass] ([ClaName], [ClaParId], [ClaNavIdList], [ClaDis], [iCount], [Depth], [SpellName], [ClaNavIdList1], [ClaSort]) VALUES (@ClaName, @ClaParId, @ClaNavIdList, @ClaDis, @iCount, @Depth, @SpellName, @ClaNavIdList1, @ClaSort)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT * FROM [AskClass] WHERE ([ClaId] = @ClaId)" 
            UpdateCommand="UPDATE [AskClass] SET [ClaName] = @ClaName, [ClaParId] = @ClaParId, [ClaNavIdList] = @ClaNavIdList, [ClaDis] = @ClaDis, [iCount] = @iCount, [Depth] = @Depth, [SpellName] = @SpellName, [ClaNavIdList1] = @ClaNavIdList1, [ClaSort] = @ClaSort WHERE [ClaId] = @original_ClaId AND [ClaName] = @original_ClaName AND [ClaParId] = @original_ClaParId AND [ClaNavIdList] = @original_ClaNavIdList AND [ClaDis] = @original_ClaDis AND [iCount] = @original_iCount AND [Depth] = @original_Depth AND [SpellName] = @original_SpellName AND [ClaNavIdList1] = @original_ClaNavIdList1 AND [ClaSort] = @original_ClaSort">
            <SelectParameters>
                <asp:controlparameter ControlID="GridView1" Name="ClaId" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <deleteparameters>
                <asp:parameter Name="original_ClaId" Type="Int32" />
                <asp:parameter Name="original_ClaName" Type="String" />
                <asp:parameter Name="original_ClaParId" Type="Int16" />
                <asp:parameter Name="original_ClaNavIdList" Type="String" />
                <asp:parameter Name="original_ClaDis" Type="Boolean" />
                <asp:parameter Name="original_iCount" Type="Int32" />
                <asp:parameter Name="original_Depth" Type="Single" />
                <asp:parameter Name="original_SpellName" Type="String" />
                <asp:parameter Name="original_ClaNavIdList1" Type="String" />
                <asp:parameter Name="original_ClaSort" Type="Int32" />
            </deleteparameters>
            <updateparameters>
                <asp:parameter Name="ClaName" Type="String" />
                <asp:parameter Name="ClaParId" Type="Int16" />
                <asp:parameter Name="ClaNavIdList" Type="String" />
                <asp:parameter Name="ClaDis" Type="Boolean" />
                <asp:parameter Name="iCount" Type="Int32" />
                <asp:parameter Name="Depth" Type="Single" />
                <asp:parameter Name="SpellName" Type="String" />
                <asp:parameter Name="ClaNavIdList1" Type="String" />
                <asp:parameter Name="ClaSort" Type="Int32" />
                <asp:parameter Name="original_ClaId" Type="Int32" />
                <asp:parameter Name="original_ClaName" Type="String" />
                <asp:parameter Name="original_ClaParId" Type="Int16" />
                <asp:parameter Name="original_ClaNavIdList" Type="String" />
                <asp:parameter Name="original_ClaDis" Type="Boolean" />
                <asp:parameter Name="original_iCount" Type="Int32" />
                <asp:parameter Name="original_Depth" Type="Single" />
                <asp:parameter Name="original_SpellName" Type="String" />
                <asp:parameter Name="original_ClaNavIdList1" Type="String" />
                <asp:parameter Name="original_ClaSort" Type="Int32" />
            </updateparameters>
            <insertparameters>
                <asp:parameter Name="ClaName" Type="String" />
                <asp:parameter Name="ClaParId" Type="Int16" />
                <asp:parameter Name="ClaNavIdList" Type="String" />
                <asp:parameter Name="ClaDis" Type="Boolean" />
                <asp:parameter Name="iCount" Type="Int32" />
                <asp:parameter Name="Depth" Type="Single" />
                <asp:parameter Name="SpellName" Type="String" />
                <asp:parameter Name="ClaNavIdList1" Type="String" />
                <asp:parameter Name="ClaSort" Type="Int32" />
            </insertparameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Gridview" runat="server" 
            ConnectionString="<%$ ConnectionStrings:mrsosoConnectionString %>" 
            SelectCommand="SELECT * FROM [AskClass]"></asp:SqlDataSource>
    
    </div>
      <div>
           <div style="font-size:9pt; float:left; width:60%">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" 
        CellPadding="4" DataKeyNames="ClaId" DataSourceID="Gridview" 
        GridLines="Horizontal" onselectedindexchanged="GridView1_SelectedIndexChanged1" 
        Width="100%">
        <footerstyle backcolor="White" forecolor="#333333" />
        <rowstyle backcolor="White" forecolor="#333333" />
        <columns>
            <asp:commandfield ShowSelectButton="True"></asp:commandfield>
            <asp:boundfield DataField="ClaId" HeaderText="编号" InsertVisible="False" 
                ReadOnly="True" SortExpression="ClaId"></asp:boundfield>
            <asp:boundfield DataField="ClaName" HeaderText="分类名" SortExpression="ClaName">
            </asp:boundfield>
        </columns>
        <pagerstyle backcolor="#336666" forecolor="White" horizontalalign="Center" />
        <selectedrowstyle backcolor="#339966" font-bold="True" forecolor="White" />
        <headerstyle backcolor="#336666" font-bold="True" forecolor="White" />
    </asp:GridView>
    </div>
    <div style="font-size:9pt; float:left; width:15%; margin-left:50px;">    
        <asp:DetailsView ID="DetailsView1" runat="server" 
            BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
            CellPadding="2" DataSourceID="detailView" ForeColor="Black" GridLines="None" 
            Height="50px" Width="125px">
            <footerstyle backcolor="Tan" />
            <pagerstyle backcolor="PaleGoldenrod" forecolor="DarkSlateBlue" 
                horizontalalign="Center" />
            <fields>
                <asp:templatefield HeaderText="名字" SortExpression="ClaName">
                    <edititemtemplate>
              
                        <cc1:FormValidation ID="TextBox1" runat="server" Text='<%# Bind("ClaName") %>' 
                            datatype="Require"  是否验试="验试" 验证表单名="form1"></cc1:FormValidation>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="TextBox1" ErrorMessage="不能空"></asp:RequiredFieldValidator>
                    </edititemtemplate>
                    <insertitemtemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ClaName") %>'></asp:TextBox>
                    </insertitemtemplate>
                    <itemtemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("ClaName") %>'></asp:Label>
                    </itemtemplate>
                </asp:templatefield>
                <asp:commandfield ShowEditButton="True"></asp:commandfield>
            </fields>
            <headerstyle backcolor="Tan" font-bold="True" />
            <editrowstyle backcolor="DarkSlateBlue" forecolor="GhostWhite" />
            <alternatingrowstyle backcolor="PaleGoldenrod" />
        </asp:DetailsView>
    </div>
      </div>

   
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        
        </ContentTemplate>
    </asp:UpdatePanel>



    </form>
</body>
</html>
